package ca.seia.comp6521.a2.itemsetstorage;

import gnu.trove.list.TIntList;

/**
 * @author itoe
 *
 */
public class IntTriplet implements Comparable<IntTriplet>{
	private int valueOne;
	private int valueTwo;
	private int valueThree;
	

	
	public IntTriplet(int valueOne, int valueTwo, int valueThree) {
		this.valueOne =  valueOne;
		this.valueTwo = valueTwo;
		this.valueThree =  valueThree;
	}
	
	public int getItem(int index) {
		int value = -1;
		if (index == 0) {
			value = valueOne;
		} else if (index == 1){
			value = valueTwo;
		}else if (index == 2) {
			value = valueThree;
		}
		return value;
	}

	public int getValueOne() {
		return valueOne;
	}

	public void setValueOne(int valueOne) {
		this.valueOne = valueOne;
	}

	public int getValueTwo() {
		return valueTwo;
	}

	public void setValueTwo(int valueTwo) {
		this.valueTwo = valueTwo;
	}

	public int getValueThree() {
		return valueThree;
	}

	public void setValueThree(int valueThree) {
		this.valueThree = valueThree;
	}
	
	public boolean containsAtLeastOneItem(TIntList infrequentItems) {
		boolean containsAtLeastOneItem = false;
		
		if(infrequentItems.contains(valueOne)) {
			containsAtLeastOneItem =  true;
		}else if(infrequentItems.contains(valueTwo)) {
			containsAtLeastOneItem =  true;
		}else if(infrequentItems.contains(valueTwo)) {
			containsAtLeastOneItem =  true;
		}
		return containsAtLeastOneItem;
	}
	
	@Override
	public int compareTo(IntTriplet o) {
		
		if(this.valueOne > o.valueOne) {
			return 1;
		} else if (this.valueOne < o.valueOne) {
			return -1;
		}else if(this.valueTwo > o.valueTwo) {
			return 1;
		}else if(this.valueTwo < o.valueTwo) {
			return -1;
		}else if(this.valueThree > o.valueThree) {
			return 1;
		}else if(this.valueThree < o.valueThree) {
			return -1;
		}
		return 0;
	}
	
	

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + valueOne;
		result = prime * result + valueThree;
		result = prime * result + valueTwo;
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		IntTriplet other = (IntTriplet) obj;
		if (valueOne != other.valueOne)
			return false;
		if (valueThree != other.valueThree)
			return false;
		if (valueTwo != other.valueTwo)
			return false;
		return true;
	}

	@Override
	public String toString() {
		return "IntTriplet [valueOne=" + valueOne + ", valueTwo=" + valueTwo + ", valueThree=" + valueThree + "]";
	}
	
	
}
